﻿using System;
using System.Collections.Generic;
using System.Web;

namespace WxPayAPI
{
    /**
    * 	配置账号信息
    */
    public class WxPayConfig
    {
        //=======【基本信息设置】=====================================
        /* 微信公众号信息配置
        * APPID：绑定支付的APPID（必须配置）
        * MCHID：商户号（必须配置）
        * KEY：商户支付密钥，参考开户邮件设置（必须配置）
        * APPSECRET：公众帐号secert（仅JSAPI支付的时候需要配置）
        */
        //public const string APPID = "wx231288344825cf39";//公众账号appid
        //public const string APPSECRET = "fbcf03063eb143b1a84ab0c1e6dccb07 ";//公众帐号secert
        //public const string MCHID = "1247945001";//商户号
        //public const string KEY = "d2E490E6E3582A0F14D41129771D3826";//商户支付密钥

        private static string Variable_APPID = "";//公众账号appid

        public static string APPID
        {
            get
            {
                if (string.IsNullOrEmpty(Variable_APPID))
                {
                    Variable_APPID = System.Web.Configuration.WebConfigurationManager.AppSettings["APPID"];
                }
                return WxPayConfig.Variable_APPID;
            }
        }

        public static string Variable_APPSECRET = "";//公众帐号secert

        public static string APPSECRET
        {
            get
            {
                if (string.IsNullOrEmpty(Variable_APPSECRET))
                {
                    Variable_APPSECRET = System.Web.Configuration.WebConfigurationManager.AppSettings["APPSECRET"];
                }
                return WxPayConfig.Variable_APPSECRET;
            }
        }

        public static string Variable_MCHID = "";//商户号

        public static string MCHID
        {
            get
            {
                if (string.IsNullOrEmpty(Variable_MCHID))
                {
                    Variable_MCHID = System.Web.Configuration.WebConfigurationManager.AppSettings["MCHID"];
                }
                return WxPayConfig.Variable_MCHID;
            }
        }

        public static string Variable_KEY = "";//商户支付密钥

        public static string KEY
        {
            get
            {
                if (string.IsNullOrEmpty(Variable_KEY))
                {
                    Variable_KEY = System.Web.Configuration.WebConfigurationManager.AppSettings["KEY"];
                }
                return WxPayConfig.Variable_KEY;
            }
        }

        static string url_domain = "";//网站域名

        public static string URL_Domain
        {
            get
            {
                if (string.IsNullOrEmpty(url_domain))
                {
                    url_domain = System.Web.Configuration.WebConfigurationManager.AppSettings["URL_Domain"];
                }
                return WxPayConfig.url_domain;
            }
        }

        static string weiCertificateInfo = "";//微信凭证商品详情显示

        public static string WeiCertificateInfo
        {
            get
            {
                if (string.IsNullOrEmpty(weiCertificateInfo))
                {
                    weiCertificateInfo = System.Web.Configuration.WebConfigurationManager.AppSettings["WeiCertificateInfo"];
                }
                return WxPayConfig.weiCertificateInfo;
            }
        }

        //                         
        //                  
        //=======【证书路径设置】===================================== 
        /* 证书路径,注意应该填写绝对路径（仅退款、撤销订单时需要）
        */
        public const string SSLCERT_PATH = "cert/apiclient_cert.p12";
        public const string SSLCERT_PASSWORD = "1247945001";


        //=======【支付结果通知url】===================================== 
        /* 支付结果通知回调url，用于商户接收支付结果
        */
        //public const string NOTIFY_URL =URL_Domain+"weijf/example/ResultNotifyPage.aspx";

        //=======【商户系统后台机器IP】===================================== 
        /* 此参数可手动配置也可在程序中自动获取
        */
        public const string IP = "8.8.8.8";


        //=======【代理服务器设置】===================================
        /* 默认IP和端口号分别为0.0.0.0和0，此时不开启代理（如有需要才设置）
        */
        //public const string PROXY_URL = "http://10.152.18.220:8080";

        //=======【上报信息配置】===================================
        /* 测速上报等级，0.关闭上报; 1.仅错误时上报; 2.全量上报
        */
        public const int REPORT_LEVENL = 1;

        //=======【日志级别】===================================
        /* 日志等级，0.不输出日志；1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
        */
        public const int LOG_LEVENL =3;


        static ILog wlog=null;
        public static ILog WLog
        {
            get 
            {
                if (wlog == null)
                {
                    string logTypeName = System.Web.Configuration.WebConfigurationManager.AppSettings["logTypeName"];
                    Type type = Type.GetType(logTypeName);
                    wlog = (ILog)Activator.CreateInstance(type, true);
                }
                return wlog;
            }
        
        }
    }
}